/**
 * 162. 寻找峰值
 */
class Solution7 {
    public int findPeakElement(int[] nums) {
        int left = 0, right = nums.length - 1;

        while(left < right) {
            int mid = left + (right - left) / 2;

            if(nums[mid] < nums[mid + 1]) {
                // 上升趋势
                left = mid + 1;
            } else {
                // nums[mid] > nums[mid + 1]
                // 下降趋势
                right = mid;
            }
        }

        return left;
    }
}